import React from 'react'
import { Tag } from 'antd'

export default React.createClass({
  getInitialState() {
    return {
    }
  },

  getDefaultProps() {
    return {
    }
  },
  addtags(value) {
    if ( value.keyCode === 13 ) {
      this.props.addtags(value);
      this.refs.input_tags.value = "";
    }
  },
  handleClose(key) {
    this.props.handleClose(key);
  },
  render() {
    let children = [];
    let tags = this.props.srvtags;
    for (let i = 0;i < tags.length;i++) {
      children.push(<span key={ tags[i] } ><Tag closable 
        afterClose={() => this.handleClose(tags[i])} >{tags[i]}</Tag></span>);
    }
    return (
      <div className='tagsinput_wrap'>
          <div>
              { children }
          </div>
          <input ref="input_tags" onKeyUp={this.addtags} />
      </div>
    )
  }
});
